#ifndef __GLRENDERER_H__
#define __GLRENDERER_H__
#ifdef __cplusplus
extern "C" {
#endif
    
//#include <GLES2/gl2.h>
//#include <GLES2/gl2ext.h>
#include <stdint.h>


class CVideoRenderer
{
public:
	CVideoRenderer();
	~CVideoRenderer();
	
public:
	bool initRenderer();
	void uninitRenderer();
	void renderFrame(EAGLContext *context, int video_width, int video_height, int screen_width, int screen_height, uint8_t* frame);
//    void setRenderGLContent(EAGLContext* _context);
	
private:
	enum {
		ATTRIB_VERTEX,
		ATTRIB_TEXTURE,
	};

private:
	GLuint mTextureYId;
	GLuint mTextureUId;
	GLuint mTextureVId;
	GLuint mProgramHandle;
	GLuint mPositionHandle;
	GLuint mCoordHandle;
	
	int mViewportWidth;
	int mViewportHeight;
    
    EAGLContext* context;
//    CGFloat scaleFactory = 0;
    
    uint8_t* render_frame_buffer = NULL;

private:	
	GLuint bindTexture(GLuint texture, const uint8_t *buffer, GLuint w , GLuint h);
	GLuint buildShader(const char* source, GLenum shaderType);
	GLuint buildProgram(const char* vertexShaderSource, const char* fragmentShaderSource);
};

    
#ifdef __cplusplus
}
#endif

#endif




